layui.use(['form', 'layer','laydate','upload'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,laydate = layui.laydate
	  ,upload = layui.upload
	  ,$ = layui.$;
	
		//得到action
		var action = getParameter("action");
		if(action == 'update'){
			var proTypeId = getParameter("proTypeId");
			var data = {"proTypeId":proTypeId};
			var url = "../../productType/findById.action";
			$.ajax({
				url:url,
				data:data,
				success:function(msg){
					form.val("myform", {
						  "proTypeId": msg.proTypeId
						  ,"proTypeName": msg.proTypeName
						  ,"proTypePid": msg.proTypePid
						})
				}
			});
		}
	  
	
		//查询产品类型
		  var url = "../../productType/findAllNameOrId.action";
		  var data = null;
		  $.ajax({
			  url:url,
			  data:data,
			  success:function(msg){
				  for(var i=0;i<msg.length;i++){
					  $("#proTypePid").append('<option value="'+msg[i].proTypeId+'">'+msg[i].proTypeName+'</option>');
				  }
				  form.render();//菜单渲染 把内容加载进去
			  }
		  });
		
	  form.on('submit(productTypeAdd)', function(data){
		  parent.location.reload();//父页面刷新
	});
	
	});